<!--Header-->
<div id="header">
    <form id="options" name="options" action="" method="post">
        <table cellspacing="0">
            <tr>
                <td class="short">
                    <label for="order">Trier : </label>
                </td>
                <td>
                    <p>
                        <select name="order" id=order tabindex="1">
                            <option <?php echo ($mode['order'] == 'alpha') ? 'selected="selected"' : ''; ?> value="alpha">Par ordre alphabétique</option>
                            <option <?php echo ($mode['order'] == 'page') ? 'selected="selected"' : ''; ?> value="page">Par pages</option>
                            <option <?php echo ($mode['order'] == 'date') ? 'selected="selected"' : ''; ?> value="date">Par date de modification</option>
                        </select>
                    </p>
                </td>
                <td class="short">
                    <label for="order">Filtrer : </label>
                </td>
                <td>
                    <p>
                        <select name="page" id="page" tabindex="2">
                            <option <?php echo ($mode['page'] == 'default') ? 'selected="selected"' : ''; ?> value="default">Aucune</option>
                            <?php foreach ($pages as $filter_page) { ?>
                            <option <?php echo ($mode['page'] == $filter_page) ? 'selected="selected"' : ''; ?> value="<?php echo $filter_page ?>"><?php echo $filter_page ?></option>
                            <?php } ?>
                        </select>
                    </p>
                </td>
                <td class="short">
                    <p>
                        <input type="submit" name="confirm" tabindex="8" id="confirm"
                               value="Rechercher" />
                    </p>
                </td>
            </tr>
            <tr>
                <td class="short">
                    <label for="order">Blocs par page : </label>
                </td>
                <td>
                    <p>
                        <select name="limit" id=limit tabindex="4">
                            <option <?php echo ($mode['limit'] == 2) ? 'selected="selected"' : ''; ?> value="2">2</option>
                            <option <?php echo ($mode['limit'] == 20) ? 'selected="selected"' : ''; ?> value="20">20</option>
                            <option <?php echo ($mode['limit'] == 30) ? 'selected="selected"' : ''; ?> value="30">30</option>
                        </select>
                    </p>
                </td>
                <td class="short">
                    <label for="order">Mots - clés : </label>
                </td>
                <td>
                    <p>
                        <input type="text" name="search" id="search" tabindex="6" value="<?php echo (isset($mode['search'])) ? htmlentities($mode['search'], ENT_QUOTES, "UTF-8") : ''; ?>" />
                    </p>
                </td>
                <td class="short">
                    <p>
                        <input type="reset" name="reset" id="reset" tabindex="10" value="Reset" />
                    </p>
                </td>
            </tr>
        </table>
    </form>

</div>
<hr />
<!--Main Container-->
<div id="main">
    <!--Content-->
    <div id="content">
        <p class="highlight">Nombre de blocs trouvés: <strong><?php echo $block_count; ?></strong></p>
        <table class="blocs">
            <tr class="head">
                <th>Bloc</th>
                <th>Page</th>
                <th>Date</th>
                <th>Options</th>
            </tr>
            <?php
            foreach ($blocks as $key => $block)
            {
                $class = ($key % 2 == 0) ? ' class="odd"' : '';
                echo '<tr' . $class . '>'
                ?>
                <td><a href="index.php?p=edit&id=<?php echo $block['id']; ?>"><?php echo htmlentities($block['name'], ENT_QUOTES, "UTF-8"); ?></a></td>
                <td><?php echo htmlentities($block['page'], ENT_QUOTES, "UTF-8"); ?></td>
                <td><?php echo htmlentities($block['date'], ENT_QUOTES, "UTF-8"); ?></td>
                <td><a href="index.php?p=edit&id=<?php echo $block['id']; ?>">Modifier</a>
                    					 - <a href="index.php?p=delete&id=<?php echo $block['id']; ?>">Supprimer</a>
                </td>
                </tr>			
                <?php
            }
            ?>
        </table>
        <?php
        for ($i = 0; $i < $page_count; $i++)
        {
            $active = '';
            if ($i == $page)
            {
                $active = ' active';
            }
            $current_page = $i + 1;
            echo '<span class="pagination' . $active . '"><a href=index.php?page=' . $current_page . '>' . $current_page . '</a></span>';
        }
        ?>
    </div>
</div>